package com.jyw.business.comp.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.jyw.common.core.domain.CommonResult;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jyw.common.annotation.Log;
import com.jyw.common.core.controller.BaseController;
import com.jyw.common.core.domain.AjaxResult;
import com.jyw.common.enums.BusinessType;
import com.jyw.business.comp.domain.CompScheduleUserPlan;
import com.jyw.business.comp.service.ICompScheduleUserPlanService;
import com.jyw.common.utils.poi.ExcelUtil;
import com.jyw.common.core.page.TableDataInfo;

/**
 * 主键-综合排班人员记录Controller
 * 
 * @author ruoyi
 * @date 2023-12-25
 */
@RestController
@RequestMapping("/comp/user/plan")
public class CompScheduleUserPlanController extends BaseController
{
    @Autowired
    private ICompScheduleUserPlanService compScheduleUserPlanService;

    /**
     * 查询主键-综合排班人员记录列表
     */
    @PreAuthorize("@ss.hasPermi('comp:user:plan:list')")
    @GetMapping("/list")
    public TableDataInfo<CompScheduleUserPlan> list(CompScheduleUserPlan compScheduleUserPlan)
    {
        startPage();
        List<CompScheduleUserPlan> list = compScheduleUserPlanService.selectCompScheduleUserPlanList(compScheduleUserPlan);
        return getDataTable(list);
    }

    /**
     * 导出主键-综合排班人员记录列表
     */
    @PreAuthorize("@ss.hasPermi('comp:user:plan:export')")
    @Log(title = "主键-综合排班人员记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CompScheduleUserPlan compScheduleUserPlan)
    {
        List<CompScheduleUserPlan> list = compScheduleUserPlanService.selectCompScheduleUserPlanList(compScheduleUserPlan);
        ExcelUtil<CompScheduleUserPlan> util = new ExcelUtil<CompScheduleUserPlan>(CompScheduleUserPlan.class);
        util.exportExcel(response, list, "主键-综合排班人员记录数据");
    }

    /**
     * 获取主键-综合排班人员记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('comp:user:plan:query')")
    @GetMapping(value = "/{id}")
    public CommonResult<CompScheduleUserPlan> getInfo(@PathVariable("id") Long id)
    {
        return CommonResult.success(compScheduleUserPlanService.selectCompScheduleUserPlanById(id));
    }

    /**
     * 新增主键-综合排班人员记录
     */
    @PreAuthorize("@ss.hasPermi('comp:user:plan:add')")
    @Log(title = "主键-综合排班人员记录", businessType = BusinessType.INSERT)
    @PostMapping
    public CommonResult add(@RequestBody CompScheduleUserPlan compScheduleUserPlan)
    {
        return CommonResult.success(compScheduleUserPlanService.insertCompScheduleUserPlan(compScheduleUserPlan));
    }

    /**
     * 修改主键-综合排班人员记录
     */
    @PreAuthorize("@ss.hasPermi('comp:user:plan:edit')")
    @Log(title = "主键-综合排班人员记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public CommonResult edit(@RequestBody CompScheduleUserPlan compScheduleUserPlan)
    {
        return CommonResult.success(compScheduleUserPlanService.updateCompScheduleUserPlan(compScheduleUserPlan));
    }

    /**
     * 删除主键-综合排班人员记录
     */
    @PreAuthorize("@ss.hasPermi('comp:user:plan:remove')")
    @Log(title = "主键-综合排班人员记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public CommonResult remove(@PathVariable Long[] ids)
    {
        return CommonResult.success(compScheduleUserPlanService.deleteCompScheduleUserPlanByIds(ids));
    }
}
